<template>
  <div class="flow-container">
  <div class="search-result-page">
    <div>
      <h2>帖子结果</h2>
      <div v-if="postList.length === 0">暂无相关帖子</div>
      <div v-else class="post-list">
        <a v-for="post in postList" :key="post.id" :href="`/forum/${post.id}`" target="_blank" style="text-decoration:none;">
          <div class="post-item" style="cursor:pointer;">
            <div class="post-item-layout">
              <h4 class="post-title">{{ post.title }}</h4>
              <p class="post-content">{{ post.content }}</p>
              <div class="post-meta">
                作者：{{ post.author }} &nbsp; 点赞：{{ post.likes }} &nbsp; 时间：{{ formatTime(post.time) }}
              </div>
            </div>
          </div>
        </a>
      </div>

      <h2>资源结果</h2>
      <div v-if="resourceList.length === 0">暂无相关资源</div>
      <div v-else class="post-list">
        <div
          v-for="resource in resourceList"
          :key="resource.id"
          class="post-item"
          style="cursor:pointer; position: relative;"
        >
          <router-link
            :to="`/resource/${resource.id}`"
            style="text-decoration:none; display: block; width: 100%; height: 100%;"
          >
            <div class="post-item-layout">
              <h4 class="post-title">{{ resource.title }}</h4>
              <p class="post-content">{{ resource.description || resource.desc || '' }}</p>
            </div>
          </router-link>
          <div class="resource-actions" @click.stop style="margin-top: 8px; position: absolute; right: 18px; bottom: 48px; z-index: 2;">
            <el-button
              :class="['like-btn', { liked: resource.isLiked }]"
              @click="toggleLike(resource, $event)"
              size="small"
            >
              <span v-html="resource.isLiked ? likeSvgPurple : likeSvgGray" style="vertical-align: middle;"></span>
              <span style="margin-left: 6px;">{{ resource.likeCount ?? 0 }}</span>
            </el-button>
            <el-button @click="download(resource, $event)" size="small">下载</el-button>
          </div>
          <div class="post-meta resource-meta">
            上传者：{{ resource.author || resource.uploader || resource.userName || '未知' }}
            &nbsp; 下载：{{ resource.downloads ?? resource.downloadCount ?? 0 }}
            &nbsp; 时间：{{ formatTime(resource.time || resource.create_time || resource.createTime) }}
          </div>
        </div>
      </div>

      <div v-if="errorMsg" class="error-msg">{{ errorMsg }}</div>
    </div>
  </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, watch } from 'vue'
import { useRoute } from 'vue-router'
import { getResourceList } from '@/api/resources'
import { getPosts, likePost, unlikePost, hasLiked, getLikeCount } from '@/api/post'
import { useForumStore } from '@/stores/forum'
import { storeToRefs } from 'pinia'
import { likeResource, unlikeResource, hasLikedResource, downloadResource, getResourceLikeCount } from '@/api/resources'
import { ElMessage } from 'element-plus'
import { useUserStore } from '@/stores/user'

const route = useRoute()
const keyword = ref(route.query.keyword as string || '')
const postList = ref<any[]>([])
const resourceList = ref<any[]>([])
const errorMsg = ref('')

const forumStore = useForumStore()
const { posts: storePosts, loading: postsLoading } = storeToRefs(forumStore)

const userStore = useUserStore()
const userId = Number(userStore.id || 1)

const likeSvgGray = `<svg t="1751619712990" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6069" width="22" height="22"><path d="M939.358251 423.424662c-23.01825-37.252439-62.924121-60.779272-107.019409-63.209624-2.755764-0.38681-5.510504-0.579191-8.347109-0.579191l-152.202471-0.121773c6.649444-28.975938 10.015098-58.653865 10.015098-88.657202 0-28.223808-3.213181-57.139372-9.556657-85.952604-0.447185-2.043542-1.098008-4.006244-1.932002-5.866614-15.820314-57.302077-67.37755-96.841605-127.282918-96.841605-72.827679 0-132.081201 59.254545-132.081201 132.081201 0 3.334955 0.132006 6.66991 0.406253 10.015098-2.196015 57.211003-32.108279 109.947088-80.269162 141.363611-14.447037 9.42465-18.524912 28.773324-9.099239 43.220361 9.414417 14.437827 28.752858 18.535145 43.220361 9.099239 65.811892-42.925648 106.429984-115.325585 108.656699-193.684234 0.030699-1.332345-0.010233-2.663666-0.14224-3.996011-0.203638-2.012843-0.304945-4.016477-0.304945-6.019087 0-38.381146 31.233352-69.614497 69.614497-69.614497 32.57593 0 60.474326 22.204721 67.824735 53.997821 0.356111 1.534959 0.823761 3.019777 1.402953 4.453429 4.696975 22.814612 7.076162 45.579081 7.076162 67.743894 0 37.485753-6.222725 74.352405-18.494213 109.592001-3.324722 9.546424-1.819438 20.111037 4.02671 28.345582 5.856381 8.245801 15.332197 13.146415 25.448602 13.156648l193.226816 0.101307c1.423419 0.264013 2.857071 0.426719 4.300956 0.477884 24.116257 0.9967 45.935192 13.614066 58.603723 34.090423 7.838525 12.31242 11.438517 26.800389 10.431583 41.939181-0.080841 0.945535-0.121773 1.911536-0.11154 2.877537 0 0.854461 0.040932 1.697665 0.11154 2.53166 0.010233 0.335644-0.030699 0.661056-0.11154 0.976234-0.101307 0.376577-0.193405 0.772596-0.284479 1.159406l-74.972529 330.391802c-0.914836 1.281179-1.738597 2.6432-2.449795 4.046153-5.937223 11.762905-14.660908 21.48329-25.346271 28.172643-10.746762 6.812149-23.059182 10.614755-35.757388 11.06194-0.854461-0.061398-513.766226-0.224104-513.766226-0.224104-0.467651-0.020466-0.935302-0.030699-1.402953-0.030699 0 0-111.01542 0.172939-112.718201 0.457418-1.932002 0-3.446495-1.50426-3.446495-3.415796l0.299829-416.334173c0-1.901303 1.545192-3.446495 3.01466-3.456728l1.245364 0.121773c1.174756 0.132006 2.653433 0.284479 3.52836 0.193405l83.82822-0.222057 0 339.367221c0 17.253966 13.979386 31.233352 31.233352 31.233352s31.233352-13.979386 31.233352-31.233352L281.009092 435.350273c0-1.778506 0-8.631588 0-10.411117 0-17.253966-13.979386-30.928407-31.233352-30.928407-1.50426 0-117.547183 0.304945-119.402437 0.304945-36.34272 0-65.913199 29.566386-65.913199 65.893756l-0.299829 416.334173c0 36.337603 29.571503 65.902966 65.913199 65.902966 2.541893 0 111.406323-0.457418 111.406323-0.457418 0.457418 0.020466 0.925069 0.030699 1.382487 0.030699 0 0 511.458671 0.274246 512.505513 0.274246 25.469068 0 50.296523-7.197936 71.647807-20.73116 19.612687-12.281721 35.777855-29.881564 46.839795-50.967812 3.660366-5.622044 6.435573-11.875468 8.256034-18.615986 0.11154-0.416486 0.213871-0.823761 0.304945-1.240247l74.881454-330.340637c1.596358-6.212492 2.257413-12.586666 2.00261-18.992563C960.892707 473.366098 953.948551 446.331371 939.358251 423.424662z" fill="#8a8a8a" p-id="6070"></path><path d="M450.027553 518.650467c-17.253966 0-31.233352 13.979386-31.233352 31.233352l0 30.470989c0 17.253966 13.979386 31.233352 31.233352 31.233352 17.253966 0 31.233352-13.979386 31.233352-31.233352l0-30.470989C481.260905 532.629853 467.281519 518.650467 450.027553 518.650467z" fill="#8a8a8a" p-id="6071"></path><path d="M693.805696 518.650467c-17.253966 0-31.233352 13.979386-31.233352 31.233352l0 30.470989c0 17.253966 13.979386 31.233352 31.233352 31.233352 17.253966 0 31.233352-13.979386 31.233352-31.233352l0-30.470989C725.039048 532.629853 711.058638 518.650467 693.805696 518.650467z" fill="#8a8a8a" p-id="6072"></path><path d="M648.940882 660.09492c-14.304797-9.393951-33.592073-5.398964-43.159986 8.763594-0.132006 0.193405-13.614066 19.754926-34.171264 19.754926-19.98824 0-32.423457-18.09717-33.266661-19.368116-9.17087-14.427594-28.254507-18.809391-42.834574-9.770528-14.650675 9.109472-19.155269 28.366048-10.055007 43.016723 11.214413 18.047028 41.96988 48.588625 86.156242 48.588625 43.962258 0 75.104535-30.318516 86.572728-48.222281C667.404396 688.461991 663.216004 669.500127 648.940882 660.09492z" fill="#8a8a8a" p-id="6073"></path></svg>`
const likeSvgPurple = `<svg t="1751619712990" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6069" width="22" height="22"><path d="M939.358251 423.424662c-23.01825-37.252439-62.924121-60.779272-107.019409-63.209624-2.755764-0.38681-5.510504-0.579191-8.347109-0.579191l-152.202471-0.121773c6.649444-28.975938 10.015098-58.653865 10.015098-88.657202 0-28.223808-3.213181-57.139372-9.556657-85.952604-0.447185-2.043542-1.098008-4.006244-1.932002-5.866614-15.820314-57.302077-67.37755-96.841605-127.282918-96.841605-72.827679 0-132.081201 59.254545-132.081201 132.081201 0 3.334955 0.132006 6.66991 0.406253 10.015098-2.196015 57.211003-32.108279 109.947088-80.269162 141.363611-14.447037 9.42465-18.524912 28.773324-9.099239 43.220361 9.414417 14.437827 28.752858 18.535145 43.220361 9.099239 65.811892-42.925648 106.429984-115.325585 108.656699-193.684234 0.030699-1.332345-0.010233-2.663666-0.14224-3.996011-0.203638-2.012843-0.304945-4.016477-0.304945-6.019087 0-38.381146 31.233352-69.614497 69.614497-69.614497 32.57593 0 60.474326 22.204721 67.824735 53.997821 0.356111 1.534959 0.823761 3.019777 1.402953 4.453429 4.696975 22.814612 7.076162 45.579081 7.076162 67.743894 0 37.485753-6.222725 74.352405-18.494213 109.592001-3.324722 9.546424-1.819438 20.111037 4.02671 28.345582 5.856381 8.245801 15.332197 13.146415 25.448602 13.156648l193.226816 0.101307c1.423419 0.264013 2.857071 0.426719 4.300956 0.477884 24.116257 0.9967 45.935192 13.614066 58.603723 34.090423 7.838525 12.31242 11.438517 26.800389 10.431583 41.939181-0.080841 0.945535-0.121773 1.911536-0.11154 2.877537 0 0.854461 0.040932 1.697665 0.11154 2.53166 0.010233 0.335644-0.030699 0.661056-0.11154 0.976234-0.101307 0.376577-0.193405 0.772596-0.284479 1.159406l-74.972529 330.391802c-0.914836 1.281179-1.738597 2.6432-2.449795 4.046153-5.937223 11.762905-14.660908 21.48329-25.346271 28.172643-10.746762 6.812149-23.059182 10.614755-35.757388 11.06194-0.854461-0.061398-513.766226-0.224104-513.766226-0.224104-0.467651-0.020466-0.935302-0.030699-1.402953-0.030699 0 0-111.01542 0.172939-112.718201 0.457418-1.932002 0-3.446495-1.50426-3.446495-3.415796l0.299829-416.334173c0-1.901303 1.545192-3.446495 3.01466-3.456728l1.245364 0.121773c1.174756 0.132006 2.653433 0.284479 3.52836 0.193405l83.82822-0.222057 0 339.367221c0 17.253966 13.979386 31.233352 31.233352 31.233352s31.233352-13.979386 31.233352-31.233352L281.009092 435.350273c0-1.778506 0-8.631588 0-10.411117 0-17.253966-13.979386-30.928407-31.233352-30.928407-1.50426 0-117.547183 0.304945-119.402437 0.304945-36.34272 0-65.913199 29.566386-65.913199 65.893756l-0.299829 416.334173c0 36.337603 29.571503 65.902966 65.913199 65.902966 2.541893 0 111.406323-0.457418 111.406323-0.457418 0.457418 0.020466 0.925069 0.030699 1.382487 0.030699 0 0 511.458671 0.274246 512.505513 0.274246 25.469068 0 50.296523-7.197936 71.647807-20.73116 19.612687-12.281721 35.777855-29.881564 46.839795-50.967812 3.660366-5.622044 6.435573-11.875468 8.256034-18.615986 0.11154-0.416486 0.213871-0.823761 0.304945-1.240247l74.881454-330.340637c1.596358-6.212492 2.257413-12.586666 2.00261-18.992563C960.892707 473.366098 953.948551 446.331371 939.358251 423.424662z" fill="#854efc" p-id="6070"></path><path d="M450.027553 518.650467c-17.253966 0-31.233352 13.979386-31.233352 31.233352l0 30.470989c0 17.253966 13.979386 31.233352 31.233352 31.233352 17.253966 0 31.233352-13.979386 31.233352-31.233352l0-30.470989C481.260905 532.629853 467.281519 518.650467 450.027553 518.650467z" fill="#854efc" p-id="6071"></path><path d="M693.805696 518.650467c-17.253966 0-31.233352 13.979386-31.233352 31.233352l0 30.470989c0 17.253966 13.979386 31.233352 31.233352 31.233352 17.253966 0 31.233352-13.979386 31.233352-31.233352l0-30.470989C725.039048 532.629853 711.058638 518.650467 693.805696 518.650467z" fill="#854efc" p-id="6072"></path><path d="M648.940882 660.09492c-14.304797-9.393951-33.592073-5.398964-43.159986 8.763594-0.132006 0.193405-13.614066 19.754926-34.171264 19.754926-19.98824 0-32.423457-18.09717-33.266661-19.368116-9.17087-14.427594-28.254507-18.809391-42.834574-9.770528-14.650675 9.109472-19.155269 28.366048-10.055007 43.016723 11.214413 18.047028 41.96988 48.588625 86.156242 48.588625 43.962258 0 75.104535-30.318516 86.572728-48.222281C667.404396 688.461991 663.216004 669.500127 648.940882 660.09492z" fill="#854efc" p-id="6073"></path></svg>`

const toggleLike = async (item: any, e: Event) => {
  e.stopPropagation()
  if (item.isLiked) {
    const res = await unlikeResource(item.id, userId)
    if (res.code === 200) {
      item.isLiked = false
      item.likeCount = (item.likeCount || 1) - 1
      ElMessage.success('取消点赞成功')
    } else {
      ElMessage.error(res.message || '取消点赞失败')
    }
  } else {
    const hasLikeRes = await hasLikedResource(item.id, userId)
    if (hasLikeRes && (hasLikeRes.code === 0 || hasLikeRes.code === 200) && hasLikeRes.data === true) {
      ElMessage.info('已经点过赞了')
      item.isLiked = true
      return
    }
    const res = await likeResource(item.id, userId)
    if (res.code === 200) {
      item.isLiked = true
      item.likeCount = (item.likeCount || 0) + 1
      ElMessage.success('点赞成功')
    } else {
      ElMessage.error(res.message || '点赞失败')
    }
  }
}

const downloadLoading = ref<{[key:number]: boolean}>({})
const download = async (item: any, e: Event) => {
  e.stopPropagation()
  if (downloadLoading.value[item.id]) return
  downloadLoading.value[item.id] = true
  item.downloadCount = (item.downloadCount || 0) + 1
  try {
    const res = await downloadResource(item.id, userId)
    if (res && res.fileUrl) {
      window.open(res.fileUrl, '_blank')
    } else {
      item.downloadCount = (item.downloadCount || 1) - 1
      ElMessage.error(res.message || '下载失败，未获取到文件地址')
    }
  } catch (err: any) {
    item.downloadCount = (item.downloadCount || 1) - 1
    ElMessage.error(err.message || '下载失败')
  } finally {
    downloadLoading.value[item.id] = false
  }
}

// 帖子点赞
const togglePostLike = async (item: any, e: Event) => {
  e.stopPropagation()
  if (item.isLiked) {
    const res = await unlikePost(item.id, userId)
    if (res.code === 200) {
      item.isLiked = false
      item.likes = (item.likes || 1) - 1
      ElMessage.success('取消点赞成功')
    } else {
      ElMessage.error(res.message || '取消点赞失败')
    }
  } else {
    const hasLikeRes = await hasLiked(item.id, userId)
    if (hasLikeRes && (hasLikeRes.code === 0 || hasLikeRes.code === 200) && hasLikeRes.data === true) {
      ElMessage.info('已经点过赞了')
      item.isLiked = true
      return
    }
    const res = await likePost(item.id, userId)
    if (res.code === 200) {
      item.isLiked = true
      item.likes = (item.likes || 0) + 1
      ElMessage.success('点赞成功')
    } else {
      ElMessage.error(res.message || '点赞失败')
    }
  }
}

// 帖子下载（占位）
const downloadPost = (item: any, e: Event) => {
  e.stopPropagation()
  ElMessage.info('下载功能暂未实现')
}

// 时间格式化函数（只显示年月日）
function formatTime(val: any) {
  if (!val) return ''
  let date: Date
  if (typeof val === 'number') {
    date = new Date(val)
  } else if (typeof val === 'string') {
    // 兼容时间戳字符串和 ISO 字符串
    if (/^\d+$/.test(val)) {
      date = new Date(Number(val))
    } else {
      // 只取前10位（yyyy-MM-dd）
      return val.slice(0, 10)
    }
    if (isNaN(date.getTime())) return val
  } else {
    return ''
  }
  const y = date.getFullYear()
  const m = (date.getMonth() + 1).toString().padStart(2, '0')
  const d = date.getDate().toString().padStart(2, '0')
  return `${y}-${m}-${d}`
}

// 搜索结果资源初始化 isLiked/likeCount 字段
watch(resourceList, (list) => {
  list.forEach(async (item) => {
    if (typeof item.isLiked === 'undefined') {
      const res = await hasLikedResource(item.id, userId)
      item.isLiked = !!(res && (res.code === 0 || res.code === 200) && res.data === true)
    }
    if (typeof item.likeCount === 'undefined') {
      const res = await getResourceLikeCount(item.id)
      item.likeCount = (res && (res.code === 0 || res.code === 200)) ? res.data : 0
    }
  })
}, { immediate: true })

const onSearch = async () => {
  errorMsg.value = ''
  try {
    // 远程搜索帖子
    let postRes = await getPosts({ keyword: keyword.value })
    console.log('原始帖子数据', postRes)
    postList.value = (postRes.list || []).map(post => ({
      ...post,
      author: post.author || post.authorId || '未知',
      likes: post.likes ?? post.like_count ?? post.likeCount ?? 0,
      time: post.time || post.create_time || post.createTime || ''
    }))
    console.log('postList.value', postList.value)
    // 搜索资源
    const resourceRes = await getResourceList({ pageNum: 1, pageSize: 10, keyword: keyword.value })
    console.log('原始资源数据', resourceRes)
    resourceList.value = (resourceRes.data?.records || []).map(resource => ({
      ...resource,
      time: resource.time || resource.create_time || resource.createTime || resource.createdAt || ''
    }))
    console.log('resourceList.value', resourceList.value) // 这里打印渲染用的数据
    if (postList.value.length === 0 && resourceList.value.length === 0) {
      errorMsg.value = '未找到相关内容'
    }
  } catch (e: any) {
    errorMsg.value = e.message || '搜索失败'
    // 不再清空 postList/resourceList，保留原有内容，便于调试
  }
}

// 监听 keyword 变化，自动搜索
watch(
  () => route.query.keyword,
  (newKeyword) => {
    keyword.value = newKeyword as string || ''
    if (keyword.value.trim()) {
      onSearch()
    }
  }
)

onMounted(() => {
  if (keyword.value && keyword.value.trim() !== '') {
    onSearch()
  }
})
</script>

<style scoped>
.search-result-page {
  width: 1000px;
  margin: 0 auto;
  padding: 24px;
  background: var(--bg-primary);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  min-height: 80vh;
  overflow-y: auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-result-page:hover {
  border-color: var(--light-purple);
  box-shadow: var(--shadow-purple);
}

h2 {
  color: var(--primary-blue);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 32px 0 20px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  position: relative;
}

h2::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--gradient-purple);
}

h2:first-of-type {
  margin-top: 0;
}

.search-input {
  width: 300px;
  margin-right: 12px;
}

.error-msg {
  margin: 24px 0;
  color: #ef4444;
  text-align: center;
  padding: 16px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* 帖子和资源列表样式 */
.post-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.post-item {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 20px;
  position: relative;
  min-height: 120px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  overflow: hidden;
}

.post-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-purple);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.post-item:hover::before {
  transform: scaleX(1);
}

.post-item:hover {
  box-shadow: var(--shadow-lg);
  background: var(--bg-secondary);
  transform: translateY(-4px);
  border-color: var(--primary-purple);
}

.post-item:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.post-item-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
}

.post-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
  transition: color 0.3s ease;
}

.post-item:hover .post-title {
  color: var(--primary-purple);
}

.post-content {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.resource-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  position: absolute;
  right: 20px;
  bottom: 50px;
  z-index: 2;
}

.resource-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  z-index: 1;
}

.like-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 12px;
}

.like-btn:hover {
  border-color: var(--primary-purple);
  background: var(--light-purple);
  transform: translateY(-1px);
}

.like-btn.liked {
  background: var(--light-purple);
  border-color: var(--primary-purple);
  color: var(--primary-purple);
}

:deep(.el-button) {
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-light);
}

:deep(.el-button:hover) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

:deep(.el-button--primary) {
  background: var(--gradient-purple);
  border: none;
  color: #ffffff;
}

:deep(.el-button--primary:hover) {
  background: linear-gradient(135deg, #9333ea 0%, #6d28d9 100%);
  box-shadow: var(--shadow-purple);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .search-result-page {
    margin: 12px;
    padding: 16px;
  }
  
  .post-item {
    padding: 16px;
    min-height: 100px;
  }
  
  .resource-actions {
    position: static;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(124, 58, 237, 0.1);
  }
  
  .post-meta, .resource-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  h2 {
    font-size: 1.25rem;
  }
}
</style>
